Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates tar distribution to conform to changes in install demo configuration script in security plugin #4250

Merged

Conversation

DarshitChanpura
Copy link
Member

@DarshitChanpura DarshitChanpura commented Nov 29, 2023

Description

Following up on the changes to demo configuration script in security plugin, opensearch-project/security#3669, the OS supported distributions need to adapt to changes in the behavior of demo configuration script.

What has changed?

The ./opensearch-tar-install.sh will now have these execution paths:

  1. OPENSEARCH_INITIAL_ADMIN_PASSWORD value is set to a strong password: Demo configuration script execution succeeds
  2. If weak password is provided in either of the cases, tar-install.sh execution will fail.
  3. If no password is provided, the script will exit and installation will fail.

For detailed testing output, refer to this comment on the issue mentioned below.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…uration script in security plugin

Signed-off-by: Darshit Chanpura <[email protected]>
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (31cc1ef) 91.35% compared to head (840a220) 91.35%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4250   +/-   ##
=======================================
  Coverage   91.35%   91.35%           
=======================================
  Files         190      190           
  Lines        6175     6175           
=======================================
  Hits         5641     5641           
  Misses        534      534           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rishabh6788
Copy link
Collaborator

rishabh6788 commented Nov 29, 2023

Just to be clear, the user is still admin and only the password has to be provided, right?

@DarshitChanpura
Copy link
Member Author

Just to be clear, the user is still admin and only the password has to be provided, right?

Yes, correct.

@prudhvigodithi
Copy link
Collaborator

prudhvigodithi commented Dec 5, 2023

Adding @derek-ho, coming from the issue #4094, looks this change is having a problem to deal multi node cluster? Derek can you please add more details. Thank you

Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
@DarshitChanpura
Copy link
Member Author

Adding @derek-ho, coming from the issue #4094, looks this change is having a problem to deal multi node cluster? Derek can you please add more details. Thank you

This issue has been addressed now by skipping password generation and quitting the script if no custom password was provided.

@dblock
Copy link
Member

dblock commented Dec 13, 2023

Is the variable really initialAdminPassword?! All OpenSearch variables are OPENSEARCH_SOMETHING_SOMETHING, where did we deviate from this convention?

@DarshitChanpura
Copy link
Member Author

DarshitChanpura commented Dec 13, 2023

@dblock Updated the info statements and the corresponding PR: opensearch-project/security#3843
has been raised in security plugin

@DarshitChanpura
Copy link
Member Author

@prudhvigodithi @rishabh6788 Would you please review this?

Signed-off-by: Darshit Chanpura <[email protected]>
@rishabh6788
Copy link
Collaborator

I am okay with approving this change but we cannot merge this until security plugin changes have been back-ported to 2.x as it will start breaking 2.12.0 tests and benchmark runs.

@DarshitChanpura
Copy link
Member Author

DarshitChanpura commented Dec 14, 2023

I am okay with approving this change but we cannot merge this until security plugin changes have been back-ported to 2.x as it will start breaking 2.12.0 tests and benchmark runs.

The backport PR is currently waiting review: opensearch-project/security#3845

@DarshitChanpura
Copy link
Member Author

opensearch-project/security#3845 is merged and this PR is unblocked.

echo "OpenSearch 2.12.0 onwards, the OpenSearch Security Plugin introduces a change that requires an initial password for 'admin' user."
echo "Please define an environment variable 'OPENSEARCH_INITIAL_ADMIN_PASSWORD' with a strong password string."
echo "If a password is not provided, the setup will quit."
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s || exit 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After talking to @prudhvigodithi we should remove the exit 1, and add set -e to the install script, as the original design removed that due to chmod 777 /dev/shm, which has been removed some time ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More conversation with @DarshitChanpura and seems like set -e might have more impact on docker side. He will get more info on that and we will need some more discussion on it with @prudhvigodithi.

I am ok with either approach, just think it would be better if we are consistent across all distributions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set -e affects the entire file setup and analyzing that change is out of scope, IMO. @prudhvigodithi @peterzhuamazon please lmk if we should indeed use set -e. TAR is much simple to analyze and can be changed to use set -e, however, docker setup is bit more involved in terms of understanding all possible code paths. Windows however doesn't have set -e from what I understand, and hence will require some form of || exit /b 1.

So, for consistency purposes I'd vote on keeping it as is with || exit 1. This has been extensively tested on TAR, docker and Windows, and the setup works as expected with this change.

@prudhvigodithi @peterzhuamazon @rishabh6788 thoughts?

@DarshitChanpura
Copy link
Member Author

@peterzhuamazon @prudhvigodithi @rishabh6788 Could I please get reviews on this?

@peterzhuamazon
Copy link
Member

peterzhuamazon commented Jan 8, 2024

Also need @prudhvigodithi to confirm on @DarshitChanpura comment above regarding keeping the exit 1 for docker and tar, but remove for deb and rpm.

@DarshitChanpura
Copy link
Member Author

DarshitChanpura commented Jan 9, 2024

Also need @prudhvigodithi to confirm on @DarshitChanpura comment above regarding keeping the exit 1 for docker and tar, but remove for deb and rpm.

This PR only addresses TAR ball, no docker/windows/rpm/deb changes are present

@DarshitChanpura
Copy link
Member Author

@peterzhuamazon Could I get some re-reviews on this PR?

@prudhvigodithi
Copy link
Collaborator

I'm ok with exit 1, even though having set -e is better as the execution codes are directly dictated by install_demo_configuration.sh but needs proper testing on how the script would behave (using set -e) with docker etc.
@peterzhuamazon add your final thought.

@prudhvigodithi
Copy link
Collaborator

prudhvigodithi commented Jan 11, 2024

@DarshitChanpura can you please use as echo -e "This is a line with a new line.\nThis is the second line." to print statements in a new line. We dont need 3 echo lines.

@DarshitChanpura
Copy link
Member Author

echo -e maybe slightly unstable. I've used printf instead which is more stable for combining 3 lines with \n

@DarshitChanpura
Copy link
Member Author

@peterzhuamazon @prudhvigodithi @rishabh6788 Could I get some more reviews?

@@ -10,7 +10,8 @@ cd $OPENSEARCH_HOME
KNN_LIB_DIR=$OPENSEARCH_HOME/plugins/opensearch-knn/lib
##Security Plugin
if [ -d "$OPENSEARCH_HOME/plugins/opensearch-security" ]; then
bash $OPENSEARCH_HOME/plugins/opensearch-security/tools/install_demo_configuration.sh -y -i -s
printf "OpenSearch 2.12.0 onwards, the OpenSearch Security Plugin introduces a change that requires an initial password for 'admin' user. \nPlease define an environment variable 'OPENSEARCH_INITIAL_ADMIN_PASSWORD' with a strong password string. \nIf a password is not provided, the setup will quit."
Copy link
Member

@peterzhuamazon peterzhuamazon Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo -e should be used here to be consistent instead of printf.

@DarshitChanpura
Copy link
Member Author

@peterzhuamazon is there anything blocking this PR still?

@peterzhuamazon peterzhuamazon merged commit f37c31c into opensearch-project:main Jan 16, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants